package ain.standard;

import util.Vector;
import environment.Pitch;
import environment.player.Player;

public class StandardChaseAntibody extends StandardAbstractAntibody
{
	public static int ID = 3;
	
	public StandardChaseAntibody(Player player, Pitch pitch)
	{
		super(player, pitch);
	}
	
	public void execute()
	{
		// move towards the ball
		player.walk(pitch.getBall().getPosition());		
	}
	
	protected double distBallRatioValue(double ratio)
	{
		if (ratio <= 1)
		{
			return ratio/1;
		}
		else if (ratio <= 2)
		{
			return 1 - (ratio -1)/1;
		}
		else return 1;
	}
	
	protected double distBallGoalValue(double zoneNumber)
	{
		if (zoneNumber <= (1.0 / 3) * 5)
		{
			return zoneNumber / ((1.0 / 3) * 5);
		}
		if (zoneNumber <= (2.0 / 3) * 5)
		{
			return 1 - (zoneNumber - ((1.0 / 3) * 5)) / ((1.0 / 3) * 5);
		}
		
		return 0;
	}
	
	protected double imprDistBallGoalValue(double zoneNumber)
	{
		if (zoneNumber <= (1 + (4.0/3.0)))
		{
			return (zoneNumber - 1) / (4.0/3.0);
		}
		if (zoneNumber <= (1 + (8.0/3.0)))
		{
			return 1 - (zoneNumber - (1 + (4.0/3.0))) / (4.0/3.0);
		}
		
		return 0;
	}
	
	protected double distBallPlayerValue(double distance)
	{
		if (distance <= FAR_RADIUS)
		{
			return distance / FAR_RADIUS;
		}
		else return 1;
	}
	
	public int getID()
	{
		return ID;
	}
	
	public String toString()
	{
		return "Chase";
	}
}
